/**
 * 这是 渲染线程
 * 主线程 和 渲染线程  通讯  remote
 */
const btn = this.document.querySelector('#btn')

const BrowserWindow = require('electron').remote.BrowserWindow
let newWin;
window.onload = () => {
  btn.onclick = () => {
    newWin = new BrowserWindow({
      width: 500,
      height: 300
    })
    newWin.loadFile(`yellow.html`)
    newWin.on('colse', () => {
      newWin = null
    })
  }
}

const { remote } = require('electron')

let rightTemplate = [
  {
    label: '粘贴',
    accelerator: 'ctrl+c',
  },
  {
    label: '复制',
    accelerator: 'ctrl+v',
  }
]

let m = remote.Menu.buildFromTemplate(rightTemplate)

window.addEventListener('contextmenu', function (e) {
  e.preventDefault()
  m.popup({window:remote.getCurrentWindow()})
})


